<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>分类: 技术教程 | 小小程序员</title><meta name="author" content="十一星野"><meta name="copyright" content="十一星野"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="本文主要以图文的形式讲解 mall 在 Linux 环境下的部署，涉及在 Docker 容器中安装 MySQL、Redis、Nginx、RabbitMQ、MongoDB、Elasticsearch、Logstash、Kibana，以及 SpringBoot 应用部署，基于 CenterOS7.6。  #👍 相关视频教程 mall在Linux环境下的部署（基于Docker容器）_上篇open i">
<meta property="og:type" content="article">
<meta property="og:title" content="mall在Linux环境下的部署（基于Docker容器）">
<meta property="og:url" content="https://ko25891wan.gitlab.io/2024/01/e8c6aded4201.html">
<meta property="og:site_name" content="小小程序员">
<meta property="og:description" content="本文主要以图文的形式讲解 mall 在 Linux 环境下的部署，涉及在 Docker 容器中安装 MySQL、Redis、Nginx、RabbitMQ、MongoDB、Elasticsearch、Logstash、Kibana，以及 SpringBoot 应用部署，基于 CenterOS7.6。  #👍 相关视频教程 mall在Linux环境下的部署（基于Docker容器）_上篇open i">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png">
<meta property="article:published_time" content="2024-01-21T09:30:40.000Z">
<meta property="article:modified_time" content="2024-01-21T09:30:40.934Z">
<meta property="article:author" content="十一星野">
<meta property="article:tag" content="宅男,热血">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://ko25891wan.gitlab.io/2024/01/e8c6aded4201.html"><link rel="preconnect" href="//fastly.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":1,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.staticfile.org/egjs-infinitegrid/4.11.0/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '分类: 技术教程',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-01-21 17:30:40'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="小小程序员"><span class="site-name">小小程序员</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">mall在Linux环境下的部署（基于Docker容器）</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-01-21T09:30:40.000Z" title="发表于 2024-01-21 17:30:40">2024-01-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-01-21T09:30:40.934Z" title="更新于 2024-01-21 17:30:40">2024-01-21</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/">技术教程</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/">mall</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/%E9%83%A8%E7%BD%B2%E7%AF%87/">部署篇</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>9分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="mall在Linux环境下的部署（基于Docker容器）"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><article class="post-content" id="article-container"><blockquote>
<p>本文主要以图文的形式讲解 mall 在 Linux 环境下的部署，涉及在 Docker 容器中安装 MySQL、Redis、Nginx、RabbitMQ、MongoDB、Elasticsearch、Logstash、Kibana，以及 SpringBoot 应用部署，基于 <code>CenterOS7.6</code>。</p>
</blockquote>
<h2 id="👍-相关视频教程"><a href="#👍-相关视频教程" class="headerlink" title="#👍 相关视频教程"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#%F0%9F%91%8D-%E7%9B%B8%E5%85%B3%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B">#</a>👍 相关视频教程</h2><ul>
<li><a target="_blank" rel="noopener" href="https://t.zsxq.com/10qkiHcbR">mall在Linux环境下的部署（基于Docker容器）_上篇open in new window</a></li>
<li><a target="_blank" rel="noopener" href="https://t.zsxq.com/10sWwS8iM">mall在Linux环境下的部署（基于Docker容器）_下篇open in new window</a></li>
</ul>
<h2 id="Docker环境安装"><a href="#Docker环境安装" class="headerlink" title="#Docker环境安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#docker%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85">#</a>Docker环境安装</h2><ul>
<li>安装<code>yum-utils</code>：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install -y yum-utils device-mapper-persistent-data lvm2</span><br></pre></td></tr></table></figure>

<ul>
<li>为yum源添加docker仓库位置：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo</span><br></pre></td></tr></table></figure>

<ul>
<li>安装docker：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install docker-ce</span><br></pre></td></tr></table></figure>

<ul>
<li>启动docker：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl start docker</span><br></pre></td></tr></table></figure>

<h2 id="MySQL安装"><a href="#MySQL安装" class="headerlink" title="#MySQL安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#mysql%E5%AE%89%E8%A3%85">#</a>MySQL安装</h2><ul>
<li>下载MySQL<code>5.7</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull mysql:5.7</span><br></pre></td></tr></table></figure>

<ul>
<li>使用如下命令启动MySQL服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 3306:3306 --name mysql \</span><br><span class="line">-v /mydata/mysql/log:/var/log/mysql \</span><br><span class="line">-v /mydata/mysql/data:/var/lib/mysql \</span><br><span class="line">-v /mydata/mysql/conf:/etc/mysql \</span><br><span class="line">-e MYSQL_ROOT_PASSWORD=root  \</span><br><span class="line">-d mysql:5.7</span><br></pre></td></tr></table></figure>

<ul>
<li><p>参数说明</p>
<ul>
<li>-p 3306:3306：将容器的3306端口映射到主机的3306端口</li>
<li>-v &#x2F;mydata&#x2F;mysql&#x2F;conf:&#x2F;etc&#x2F;mysql：将配置文件夹挂在到主机</li>
<li>-v &#x2F;mydata&#x2F;mysql&#x2F;log:&#x2F;var&#x2F;log&#x2F;mysql：将日志文件夹挂载到主机</li>
<li>-v &#x2F;mydata&#x2F;mysql&#x2F;data:&#x2F;var&#x2F;lib&#x2F;mysql&#x2F;：将数据文件夹挂载到主机</li>
<li>-e MYSQL_ROOT_PASSWORD&#x3D;root：初始化root用户的密码</li>
</ul>
</li>
<li><p>进入运行MySQL的docker容器：</p>
</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it mysql /bin/bash</span><br></pre></td></tr></table></figure>

<ul>
<li>使用MySQL命令打开客户端：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -proot --default-character-set=utf8</span><br></pre></td></tr></table></figure>

<ul>
<li>创建mall数据库：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">create database mall character set utf8</span><br></pre></td></tr></table></figure>

<ul>
<li>安装上传下载插件，并将<code>document/sql/mall.sql</code>上传到Linux服务器上：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install lrzsz</span><br></pre></td></tr></table></figure>

<ul>
<li>将<code>mall.sql</code>文件拷贝到mysql容器的<code>/</code>目录下：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker cp /mydata/mall.sql mysql:/</span><br></pre></td></tr></table></figure>

<ul>
<li>将sql文件导入到数据库：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">use mall;</span><br><span class="line">source /mall.sql;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建一个<code>reader:123456</code>帐号并修改权限，使得任何ip都能访问：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grant all privileges on *.* to &#x27;reader&#x27; @&#x27;%&#x27; identified by &#x27;123456&#x27;;</span><br></pre></td></tr></table></figure>

<h2 id="Redis安装"><a href="#Redis安装" class="headerlink" title="#Redis安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#redis%E5%AE%89%E8%A3%85">#</a>Redis安装</h2><ul>
<li>下载Redis<code>7</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull redis:7</span><br></pre></td></tr></table></figure>

<ul>
<li>使用如下命令启动Redis服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 6379:6379 --name redis \</span><br><span class="line">-v /mydata/redis/data:/data \</span><br><span class="line">-d redis:7 redis-server --appendonly yes</span><br></pre></td></tr></table></figure>

<ul>
<li>进入Redis容器使用<code>redis-cli</code>命令进行连接：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it redis redis-cli</span><br></pre></td></tr></table></figure>

<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_new_01-bc3b0cc9.png"></p>
<h2 id="Nginx安装"><a href="#Nginx安装" class="headerlink" title="#Nginx安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#nginx%E5%AE%89%E8%A3%85">#</a>Nginx安装</h2><ul>
<li>下载Nginx<code>1.22</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull nginx:1.22</span><br></pre></td></tr></table></figure>

<ul>
<li>先运行一次容器（为了拷贝配置文件）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 80:80 --name nginx \</span><br><span class="line">-v /mydata/nginx/html:/usr/share/nginx/html \</span><br><span class="line">-v /mydata/nginx/logs:/var/log/nginx  \</span><br><span class="line">-d nginx:1.22</span><br></pre></td></tr></table></figure>

<ul>
<li>将容器内的配置文件拷贝到指定目录：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker container cp nginx:/etc/nginx /mydata/nginx/</span><br></pre></td></tr></table></figure>

<ul>
<li>修改文件名称：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mv nginx conf</span><br></pre></td></tr></table></figure>

<ul>
<li>终止并删除容器：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker stop nginx</span><br><span class="line">docker rm nginx</span><br></pre></td></tr></table></figure>

<ul>
<li>使用如下命令启动Nginx服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 80:80 --name nginx \</span><br><span class="line">-v /mydata/nginx/html:/usr/share/nginx/html \</span><br><span class="line">-v /mydata/nginx/logs:/var/log/nginx  \</span><br><span class="line">-v /mydata/nginx/conf:/etc/nginx \</span><br><span class="line">-d nginx:1.22</span><br></pre></td></tr></table></figure>

<h2 id="RabbitMQ安装"><a href="#RabbitMQ安装" class="headerlink" title="#RabbitMQ安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#rabbitmq%E5%AE%89%E8%A3%85">#</a>RabbitMQ安装</h2><ul>
<li>下载rabbitmq<code>3.9-management</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull rabbitmq:3.9-management</span><br></pre></td></tr></table></figure>

<ul>
<li>使用如下命令启动RabbitMQ服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 5672:5672 -p 15672:15672 --name rabbitmq \</span><br><span class="line">-v /mydata/rabbitmq/data:/var/lib/rabbitmq \</span><br><span class="line">-d rabbitmq:3.9-management</span><br></pre></td></tr></table></figure>

<ul>
<li>开启防火墙：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">firewall-cmd --zone=public --add-port=15672/tcp --permanent</span><br><span class="line">firewall-cmd --reload</span><br></pre></td></tr></table></figure>

<ul>
<li>访问地址查看是否安装成功：<a target="_blank" rel="noopener" href="http://192.168.3.101:15672/">http://192.168.3.101:15672</a></li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_03-78dad8ac.png"></p>
<ul>
<li><p>输入账号密码并登录：guest guest</p>
</li>
<li><p>创建帐号并设置其角色为管理员：mall mall</p>
</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_04-2fd308c9.png"></p>
<ul>
<li>创建一个新的虚拟host为：&#x2F;mall</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_05-9a7bf37b.png"></p>
<ul>
<li>点击mall用户进入用户配置页面</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_06-309462ae.png"></p>
<ul>
<li>给mall用户配置该虚拟host的权限</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_07-782ca72c.png"></p>
<h2 id="Elasticsearch安装"><a href="#Elasticsearch安装" class="headerlink" title="#Elasticsearch安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#elasticsearch%E5%AE%89%E8%A3%85">#</a>Elasticsearch安装</h2><ul>
<li>下载Elasticsearch<code>7.17.3</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull elasticsearch:7.17.3</span><br></pre></td></tr></table></figure>

<ul>
<li>修改虚拟内存区域大小，否则会因为过小而无法启动:</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sysctl -w vm.max_map_count=262144</span><br></pre></td></tr></table></figure>

<ul>
<li>使用如下命令启动Elasticsearch服务，内存小的服务器可以通过<code>ES_JAVA_OPTS</code>来设置占用内存大小：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 9200:9200 -p 9300:9300 --name elasticsearch \</span><br><span class="line">-e &quot;discovery.type=single-node&quot; \</span><br><span class="line">-e &quot;cluster.name=elasticsearch&quot; \</span><br><span class="line">-e &quot;ES_JAVA_OPTS=-Xms512m -Xmx1024m&quot; \</span><br><span class="line">-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \</span><br><span class="line">-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \</span><br><span class="line">-d elasticsearch:7.17.3</span><br></pre></td></tr></table></figure>

<ul>
<li>启动时会发现<code>/usr/share/elasticsearch/data</code>目录没有访问权限，只需要修改<code>/mydata/elasticsearch/data</code>目录的权限，再重新启动即可；</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod 777 /mydata/elasticsearch/data/</span><br></pre></td></tr></table></figure>

<ul>
<li>安装中文分词器IKAnalyzer，注意下载与Elasticsearch对应的版本，下载地址：<a target="_blank" rel="noopener" href="https://github.com/medcl/elasticsearch-analysis-ik/releases">https://github.com/medcl/elasticsearch-analysis-ik/releases</a></li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_new_02-d402f993.png"></p>
<ul>
<li>下载完成后解压到Elasticsearch的<code>/mydata/elasticsearch/plugins</code>目录下；</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_new_03-d123512a.png"></p>
<ul>
<li>重新启动服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker restart elasticsearch</span><br></pre></td></tr></table></figure>

<ul>
<li>开启防火墙：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">firewall-cmd --zone=public --add-port=9200/tcp --permanent</span><br><span class="line">firewall-cmd --reload</span><br></pre></td></tr></table></figure>

<ul>
<li>访问会返回版本信息：<a target="_blank" rel="noopener" href="http://192.168.3.101:9200/">http://192.168.3.101:9200</a></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  &quot;name&quot;: &quot;708f1d885c16&quot;,</span><br><span class="line">  &quot;cluster_name&quot;: &quot;elasticsearch&quot;,</span><br><span class="line">  &quot;cluster_uuid&quot;: &quot;mza51wT-QvaZ5R0NmE183g&quot;,</span><br><span class="line">  &quot;version&quot;: &#123;</span><br><span class="line">    &quot;number&quot;: &quot;7.17.3&quot;,</span><br><span class="line">    &quot;build_flavor&quot;: &quot;default&quot;,</span><br><span class="line">    &quot;build_type&quot;: &quot;docker&quot;,</span><br><span class="line">    &quot;build_hash&quot;: &quot;5ad023604c8d7416c9eb6c0eadb62b14e766caff&quot;,</span><br><span class="line">    &quot;build_date&quot;: &quot;2022-04-19T08:11:19.070913226Z&quot;,</span><br><span class="line">    &quot;build_snapshot&quot;: false,</span><br><span class="line">    &quot;lucene_version&quot;: &quot;8.11.1&quot;,</span><br><span class="line">    &quot;minimum_wire_compatibility_version&quot;: &quot;6.8.0&quot;,</span><br><span class="line">    &quot;minimum_index_compatibility_version&quot;: &quot;6.0.0-beta1&quot;</span><br><span class="line">  &#125;,</span><br><span class="line">  &quot;tagline&quot;: &quot;You Know, for Search&quot;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Logstash安装"><a href="#Logstash安装" class="headerlink" title="#Logstash安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#logstash%E5%AE%89%E8%A3%85">#</a>Logstash安装</h2><ul>
<li>下载Logstash<code>7.17.3</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull logstash:7.17.3</span><br></pre></td></tr></table></figure>

<ul>
<li>修改Logstash的配置文件<code>logstash.conf</code>中<code>output</code>节点下的Elasticsearch连接地址为<code>es:9200</code>，配置文件地址：<a target="_blank" rel="noopener" href="https://github.com/macrozheng/mall/blob/master/document/elk/logstash.conf">https://github.com/macrozheng/mall/blob/master/document/elk/logstash.conf</a></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">output &#123;</span><br><span class="line">  elasticsearch &#123;</span><br><span class="line">    hosts =&gt; &quot;es:9200&quot;</span><br><span class="line">    index =&gt; &quot;mall-%&#123;type&#125;-%&#123;+YYYY.MM.dd&#125;&quot;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建<code>/mydata/logstash</code>目录，并将Logstash的配置文件<code>logstash.conf</code>拷贝到该目录；</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir /mydata/logstash</span><br></pre></td></tr></table></figure>

<ul>
<li>使用如下命令启动Logstash服务；</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker run --name logstash -p 4560:4560 -p 4561:4561 -p 4562:4562 -p 4563:4563 \</span><br><span class="line">--link elasticsearch:es \</span><br><span class="line">-v /mydata/logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf \</span><br><span class="line">-d logstash:7.17.3</span><br></pre></td></tr></table></figure>

<ul>
<li>进入容器内部，安装<code>json_lines</code>插件。</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">logstash-plugin install logstash-codec-json_lines</span><br></pre></td></tr></table></figure>

<h2 id="Kibana安装"><a href="#Kibana安装" class="headerlink" title="#Kibana安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#kibana%E5%AE%89%E8%A3%85">#</a>Kibana安装</h2><ul>
<li>下载Kibana<code>7.17.3</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull kibana:7.17.3</span><br></pre></td></tr></table></figure>

<ul>
<li>使用如下命令启动Kibana服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker run --name kibana -p 5601:5601 \</span><br><span class="line">--link elasticsearch:es \</span><br><span class="line">-e &quot;elasticsearch.hosts=http://es:9200&quot; \</span><br><span class="line">-d kibana:7.17.3</span><br></pre></td></tr></table></figure>

<ul>
<li>开启防火墙：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">firewall-cmd --zone=public --add-port=5601/tcp --permanent</span><br><span class="line">firewall-cmd --reload</span><br></pre></td></tr></table></figure>

<ul>
<li>访问地址进行测试：<a target="_blank" rel="noopener" href="http://192.168.3.101:5601/">http://192.168.3.101:5601</a></li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_windows_deploy_12-5c098822.png"></p>
<h2 id="MongoDB安装"><a href="#MongoDB安装" class="headerlink" title="#MongoDB安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#mongodb%E5%AE%89%E8%A3%85">#</a>MongoDB安装</h2><ul>
<li>下载MongoDB<code>4</code>的docker镜像：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull mongo:4</span><br></pre></td></tr></table></figure>

<ul>
<li>使用docker命令启动：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 27017:27017 --name mongo \</span><br><span class="line">-v /mydata/mongo/db:/data/db \</span><br><span class="line">-d mongo:4</span><br></pre></td></tr></table></figure>

<h2 id="MinIO安装"><a href="#MinIO安装" class="headerlink" title="#MinIO安装"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#minio%E5%AE%89%E8%A3%85">#</a>MinIO安装</h2><ul>
<li>下载MinIO的Docker镜像；</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull minio/minio</span><br></pre></td></tr></table></figure>

<ul>
<li>下载完成后使用如下命令运行MinIO服务，注意使用<code>--console-address</code>指定MinIO Console的运行端口（否则会随机端口运行）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 9090:9000 -p 9001:9001 --name minio \</span><br><span class="line">-v /mydata/minio/data:/data \</span><br><span class="line">-e MINIO_ROOT_USER=minioadmin \</span><br><span class="line">-e MINIO_ROOT_PASSWORD=minioadmin \</span><br><span class="line">-d minio/minio server /data --console-address &quot;:9001&quot;</span><br></pre></td></tr></table></figure>

<ul>
<li>运行成功后就可访问MinIO Console的管理界面了，输入账号密码<code>minioadmin:minioadmin</code>即可登录，访问地址：<a target="_blank" rel="noopener" href="http://192.168.3.101:9090/">http://192.168.3.101:9090</a></li>
</ul>
<p><img src="https://www.macrozheng.com/assets/minio_console_start_01-0919577f.png"></p>
<h2 id="Docker全部环境安装完成"><a href="#Docker全部环境安装完成" class="headerlink" title="#Docker全部环境安装完成"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#docker%E5%85%A8%E9%83%A8%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85%E5%AE%8C%E6%88%90">#</a>Docker全部环境安装完成</h2><ul>
<li>所有下载镜像文件：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE</span><br><span class="line">redis                 7                   604d80444252        2 days ago          117MB</span><br><span class="line">nginx                 1.22                f9c88cc1c21a        2 weeks ago         142MB</span><br><span class="line">elasticsearch         7.17.3              3c91aa69ae06        8 weeks ago         613MB</span><br><span class="line">kibana                7.17.3              4897f4b8b6ee        8 weeks ago         797MB</span><br><span class="line">logstash              7.17.3              dd4291c803f4        8 weeks ago         774MB</span><br><span class="line">mongo                 4                   1c0f1e566fec        5 months ago        438MB</span><br><span class="line">rabbitmq              3.9-management      6c3c2a225947        6 months ago        253MB</span><br><span class="line">mysql                 5.7                 7faa3c53e6d6        3 years ago         373MB</span><br><span class="line">nginx                 1.10                0346349a1a64        5 years ago         182MB</span><br><span class="line">java                  8                   d23bdf5b1b1b        5 years ago         643MB</span><br></pre></td></tr></table></figure>

<ul>
<li>所有运行在容器里面的应用：</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_new_05-dbb53569.png"></p>
<h2 id="SpringBoot应用部署"><a href="#SpringBoot应用部署" class="headerlink" title="#SpringBoot应用部署"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#springboot%E5%BA%94%E7%94%A8%E9%83%A8%E7%BD%B2">#</a>SpringBoot应用部署</h2><h3 id="构建所有Docker镜像并上传"><a href="#构建所有Docker镜像并上传" class="headerlink" title="#构建所有Docker镜像并上传"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#%E6%9E%84%E5%BB%BA%E6%89%80%E6%9C%89docker%E9%95%9C%E5%83%8F%E5%B9%B6%E4%B8%8A%E4%BC%A0">#</a>构建所有Docker镜像并上传</h3><ul>
<li>修改项目根目录下的<code>pom.xml</code>中的<code>docker.host</code>属性：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;properties&gt;</span><br><span class="line">    &lt;docker.host&gt;http://192.168.3.101:2375&lt;/docker.host&gt;</span><br><span class="line">&lt;/properties&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>如果项目根目录的<code>pom.mxl</code>中<code>docker-maven-plugin</code>的<code>&lt;executions&gt;</code>节点被注释掉了就打开注释，使项目在打包时直接构建Docker镜像；</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_new_06-bf2e2ee0.png"></p>
<ul>
<li>直接双击根项目<code>mall</code>的<code>package</code>命令可以一次性打包所有应用的Docker镜像；</li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_12-fe095c6d.png"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE</span><br><span class="line">mall/mall-portal      1.0-SNAPSHOT        c668ea32b405        24 hours ago        712MB</span><br><span class="line">mall/mall-search      1.0-SNAPSHOT        627d1ebbc21b        24 hours ago        745MB</span><br><span class="line">mall/mall-admin       1.0-SNAPSHOT        2300aca75270        24 hours ago        725MB</span><br></pre></td></tr></table></figure>

<h3 id="部署mall-admin"><a href="#部署mall-admin" class="headerlink" title="#部署mall-admin"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#%E9%83%A8%E7%BD%B2mall-admin">#</a>部署mall-admin</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 8080:8080 --name mall-admin \</span><br><span class="line">--link mysql:db \</span><br><span class="line">--link redis:redis \</span><br><span class="line">-v /etc/localtime:/etc/localtime \</span><br><span class="line">-v /mydata/app/admin/logs:/var/logs \</span><br><span class="line">-d mall/mall-admin:1.0-SNAPSHOT</span><br></pre></td></tr></table></figure>

<p><code>注意</code>：如果想使用Logstash收集日志的话，需要将应用容器连接到Logstsh，添加如下配置即可；</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">--link logstash:logstash \</span><br></pre></td></tr></table></figure>

<h3 id="部署mall-search"><a href="#部署mall-search" class="headerlink" title="#部署mall-search"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#%E9%83%A8%E7%BD%B2mall-search">#</a>部署mall-search</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 8081:8081 --name mall-search \</span><br><span class="line">--link elasticsearch:es \</span><br><span class="line">--link mysql:db \</span><br><span class="line">-v /etc/localtime:/etc/localtime \</span><br><span class="line">-v /mydata/app/search/logs:/var/logs \</span><br><span class="line">-d mall/mall-search:1.0-SNAPSHOT</span><br></pre></td></tr></table></figure>

<h3 id="部署mall-port"><a href="#部署mall-port" class="headerlink" title="#部署mall-port"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#%E9%83%A8%E7%BD%B2mall-port">#</a>部署mall-port</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 8085:8085 --name mall-portal \</span><br><span class="line">--link mysql:db \</span><br><span class="line">--link redis:redis \</span><br><span class="line">--link mongo:mongo \</span><br><span class="line">--link rabbitmq:rabbit \</span><br><span class="line">-v /etc/localtime:/etc/localtime \</span><br><span class="line">-v /mydata/app/portal/logs:/var/logs \</span><br><span class="line">-d mall/mall-portal:1.0-SNAPSHOT</span><br></pre></td></tr></table></figure>

<h3 id="开启防火墙"><a href="#开启防火墙" class="headerlink" title="#开启防火墙"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#%E5%BC%80%E5%90%AF%E9%98%B2%E7%81%AB%E5%A2%99">#</a>开启防火墙</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">firewall-cmd --zone=public --add-port=8080/tcp --permanent</span><br><span class="line">firewall-cmd --zone=public --add-port=8081/tcp --permanent</span><br><span class="line">firewall-cmd --zone=public --add-port=8085/tcp --permanent</span><br><span class="line">firewall-cmd --reload</span><br></pre></td></tr></table></figure>

<h3 id="访问接口进行测试"><a href="#访问接口进行测试" class="headerlink" title="#访问接口进行测试"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/deploy/mall_deploy_docker.html#%E8%AE%BF%E9%97%AE%E6%8E%A5%E5%8F%A3%E8%BF%9B%E8%A1%8C%E6%B5%8B%E8%AF%95">#</a>访问接口进行测试</h3><ul>
<li>mall-admin的api接口文档地址：<a target="_blank" rel="noopener" href="http://192.168.3.101:8080/swagger-ui/">http://192.168.3.101:8080/swagger-ui/</a></li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_13-f1cb4e11.png"></p>
<ul>
<li>mall-search的api接口文档地址：<a target="_blank" rel="noopener" href="http://192.168.3.101:8081/swagger-ui/">http://192.168.3.101:8081/swagger-ui/</a></li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_14-4cc0ed38.png"></p>
<ul>
<li>mall-portal的api接口文档地址：<a target="_blank" rel="noopener" href="http://192.168.3.101:8085/swagger-ui/">http://192.168.3.101:8085/swagger-ui/</a></li>
</ul>
<p><img src="https://www.macrozheng.com/assets/mall_linux_deploy_15-5964e33a.png"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io">十一星野</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io/2024/01/e8c6aded4201.html">https://ko25891wan.gitlab.io/2024/01/e8c6aded4201.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://ko25891wan.gitlab.io" target="_blank">小小程序员</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2024/01/820726ead406.html" title="mall在Windows环境下的部署"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">mall在Windows环境下的部署</div></div></a></div><div class="next-post pull-right"><a href="/2024/01/63532e124df9.html" title="mall在Linux环境下的部署（基于Docker Compose）"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">mall在Linux环境下的部署（基于Docker Compose）</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">十一星野</div><div class="author-info__description">归途也还可爱</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io"><i class="fab fa-github"></i><span>关注我</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Gitlab"><i class="fab fa-gitlab" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:ko25891wan@outlook.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%F0%9F%91%8D-%E7%9B%B8%E5%85%B3%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B"><span class="toc-number">1.</span> <span class="toc-text">👍 相关视频教程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Docker%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85"><span class="toc-number">2.</span> <span class="toc-text">Docker环境安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#MySQL%E5%AE%89%E8%A3%85"><span class="toc-number">3.</span> <span class="toc-text">MySQL安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Redis%E5%AE%89%E8%A3%85"><span class="toc-number">4.</span> <span class="toc-text">Redis安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Nginx%E5%AE%89%E8%A3%85"><span class="toc-number">5.</span> <span class="toc-text">Nginx安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#RabbitMQ%E5%AE%89%E8%A3%85"><span class="toc-number">6.</span> <span class="toc-text">RabbitMQ安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Elasticsearch%E5%AE%89%E8%A3%85"><span class="toc-number">7.</span> <span class="toc-text">Elasticsearch安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Logstash%E5%AE%89%E8%A3%85"><span class="toc-number">8.</span> <span class="toc-text">Logstash安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Kibana%E5%AE%89%E8%A3%85"><span class="toc-number">9.</span> <span class="toc-text">Kibana安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#MongoDB%E5%AE%89%E8%A3%85"><span class="toc-number">10.</span> <span class="toc-text">MongoDB安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#MinIO%E5%AE%89%E8%A3%85"><span class="toc-number">11.</span> <span class="toc-text">MinIO安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Docker%E5%85%A8%E9%83%A8%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85%E5%AE%8C%E6%88%90"><span class="toc-number">12.</span> <span class="toc-text">Docker全部环境安装完成</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#SpringBoot%E5%BA%94%E7%94%A8%E9%83%A8%E7%BD%B2"><span class="toc-number">13.</span> <span class="toc-text">SpringBoot应用部署</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9E%84%E5%BB%BA%E6%89%80%E6%9C%89Docker%E9%95%9C%E5%83%8F%E5%B9%B6%E4%B8%8A%E4%BC%A0"><span class="toc-number">13.1.</span> <span class="toc-text">构建所有Docker镜像并上传</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%83%A8%E7%BD%B2mall-admin"><span class="toc-number">13.2.</span> <span class="toc-text">部署mall-admin</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%83%A8%E7%BD%B2mall-search"><span class="toc-number">13.3.</span> <span class="toc-text">部署mall-search</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%83%A8%E7%BD%B2mall-port"><span class="toc-number">13.4.</span> <span class="toc-text">部署mall-port</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%80%E5%90%AF%E9%98%B2%E7%81%AB%E5%A2%99"><span class="toc-number">13.5.</span> <span class="toc-text">开启防火墙</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%BF%E9%97%AE%E6%8E%A5%E5%8F%A3%E8%BF%9B%E8%A1%8C%E6%B5%8B%E8%AF%95"><span class="toc-number">13.6.</span> <span class="toc-text">访问接口进行测试</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/c60470b9a892.html" title="Java集合使用注意事项总结">Java集合使用注意事项总结</a><time datetime="2024-02-03T04:58:22.000Z" title="发表于 2024-02-03 12:58:22">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/81fb7a201f29.html" title="无题">无题</a><time datetime="2024-02-03T03:15:31.812Z" title="发表于 2024-02-03 11:15:31">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/5737c1ec69a9.html" title="Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)">Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)</a><time datetime="2024-01-31T06:56:16.000Z" title="发表于 2024-01-31 14:56:16">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/f510db7d2f19.html" title="Spring常见面试题总结">Spring常见面试题总结</a><time datetime="2024-01-31T06:55:58.000Z" title="发表于 2024-01-31 14:55:58">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/9be065e9f288.html" title="redis 面试">redis 面试</a><time datetime="2024-01-31T06:55:55.000Z" title="发表于 2024-01-31 14:55:55">2024-01-31</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2024 By 十一星野</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.staticfile.org/instant.page/5.2.0/instantpage.min.js" type="module"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>